<template>
  <el-form
    style="max-width: 600px;margin-top:10px;"
    :model="createForm"
    :rules="rules"
    label-width="auto"
    class="form_style"
    :size="formSize"
    status-icon
  >
    <h2>添加小组
      <span>请在下面如实填写店铺信息，其中星号为必填项</span>
    </h2>
    <el-form-item label="小组名：" prop="groupName">
      <el-input v-model="createForm.name"  placeholder="填写小组名"></el-input>
    </el-form-item>
    <el-form-item label="备注信息：" prop="groupNote">
      <el-input v-model="createForm.note"  placeholder="备注信息" type="textarea"></el-input>
    </el-form-item>
  <el-button type="primary" style="margin-left: 50%;" @click="Addgroup">提交</el-button>
  </el-form>
    
</template>

<script  setup>
import { reactive, ref ,onMounted} from 'vue'
import { ElMessage } from 'element-plus'
import {groupCreate } from '../../../api';

const createForm = ref({
  name:'',
  note:'',
  status:0
})

const Addgroup = async () => {
  console.log('添加内容', createForm)
  console.log('添加内容', createForm.value)
  let response = createForm.value
  //把updateForm.value给列表的第一列
  console.log('更新内容', response)
  let res = await groupCreate(response);
  console.log('查看一下', createForm)
  console.log('查看一下2', res.data)
  if (res.code == 200) {
    ElMessage({
      message: '添加成功',
      type: 'success',
      duration: 1000
    });
    document.getElementById("createForm").reset();
  } else {
    ElMessage({
      message: res.message,
      type: 'error',
      duration: 1000
    });
  }
}

const formSize = ref('default');
const rules = ref({
  groupName: [
    {
      required: true,
      message: '填写小组名',
      trigger: 'blur'
    },
  ],
  groupNote: [
    {
      message: '填写备注信息',
      trigger: 'blur',
    },
  ],
});

</script>
<style scoped>
/* 表单的样式 */
.form_style {
  margin-left:auto;
  margin-right:auto;
  max-width: 500px;
  background: #FFF;
  padding: 30px 30px 20px 30px;
  box-shadow: rgba(187, 187, 187, 1) 0 0px 20px -1px;
  -webkit-box-shadow: rgba(187, 187, 187, 1) 0 0px 20px -1px;
  font: 12px Arial, Helvetica, sans-serif;
  color: #666;
  border-radius: 10px;
  -webkit-border-radius: 10p
}
/*大标题样式*/
.form_style h2 {
  font: 24px "Trebuchet MS", Arial, Helvetica, sans-serif;
  padding: 0px 0px 10px 40px;
  display: block;
  border-bottom: 1px solid #F5F5F5;
  margin: -10px -30px 10px -30px;
  color: #354552;
}
/*小标题样式*/
.form_style h2>span {
display: block;
font-size: 12px;
}
</style>